<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<%@ attribute name="name" required="true" rtexprvalue="true" description="name of radio element" %>
<%@ attribute name="label" required="false" rtexprvalue="true" description="Label of radio element" %>
<%@ attribute name="bindPath" required="true" rtexprvalue="true" description="Bind path of radio element" %>
<%@ attribute name="widgetType" required="false" rtexprvalue="true" description="WidgetType of radio element" %>
<%@ attribute name="id" required="false" rtexprvalue="true" description="ID of radio element"%>
<%@ attribute name="optionValues" required="true" rtexprvalue="true" type="java.lang.String[]" description="Option Values" %>
<%@ attribute name="optionLabels" required="false" rtexprvalue="true" type="java.lang.String[]" description="Option Labels" %>
<%@ attribute name="hiddenLabel" required="false" rtexprvalue="true" description="Hidden Label" type="java.lang.Boolean"%>
 
<c:choose>
  <c:when test="${label == null || label == ''}">
    <c:set var="label" value="${name}" />
  </c:when>
</c:choose>
<c:choose>
  <c:when test="${id == null || id == ''}">
    <c:set var="id" value="${name}" />
  </c:when>
</c:choose>
<c:choose>
  <c:when test="${widgetType == null || widgetType == ''}">
    <c:set var="widgetType" value="dijit.form.ValidationTextBox" />
  </c:when>
</c:choose>

<c:if test="${!hiddenLabel}">
<li class="form_grid_label"><label for="${name}">${label}:</label></li>
<li class="form_grid_element">
</c:if>
<c:forEach var="_optionV" items="${optionValues}" varStatus="_optionVStatus">
<form:radiobutton id="${id}${_optionV}" path="${bindPath}" label="${optionLabels[_optionVStatus.index]}" value="${_optionV}" />
<script type="text/javascript">
      Spring
          .addDecoration(new Spring.ElementDecoration(
              {
                elementId : '${id}${_optionV}',
                widgetType : "dijit.form.RadioButton",
                widgetModule : "dijit.form.CheckBox",
                widgetAttrs : {
                  value : "${_optionV}"
                }
              }));
    </script>
</c:forEach>
<c:if test="${!hiddenLabel}">
</li>
</c:if>
